// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:get/get.dart';

import '../common/common_style.dart';

class PreSaleRulerPopop extends StatefulWidget {
  final String descriptTxt;
  const PreSaleRulerPopop({
    super.key,
    required this.descriptTxt,
  });

  @override
  State<PreSaleRulerPopop> createState() => _PreSaleRulerPopopState();
}

class _PreSaleRulerPopopState extends State<PreSaleRulerPopop> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 300.h,
      padding: EdgeInsets.all(18.w),
      decoration: border_radis(Colors.white),
      child: Column(
        children: [
          Row(
            children: [
              const Text(
                '预售规则',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
              ),
              const Spacer(),
              InkWell(
                onTap: () => Get.back(),
                child: const Icon(Icons.close),
              )
              
            ],
          ),
          Expanded(
            child: SingleChildScrollView(
              child: Padding(
                padding: const EdgeInsets.symmetric(vertical: 8.0),
                child: Text(
                  removeHtmlTags(widget.descriptTxt),
                  style: const TextStyle(fontSize: 14),
                ),
              ),
            ),
          ),
          InkWell(
            onTap: () => Get.back(),
            child: Container(
              padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 20.w),
              decoration: BoxDecoration(
                color: Tools.fromHex('#D63F27'),
                borderRadius: BorderRadius.circular(20), // 圆角
              ),
              child: const Text(
                '我知道了',
                style: TextStyle(color: Colors.white), // 字体颜色
              ),
            ),
          )
        ],
      ),
    );
  }

  String removeHtmlTags(String htmlString) {
    final RegExp regex = RegExp(r'<[^>]*>');
    return htmlString.replaceAll(regex, '');
  }
}
